package com.carrot.uaa.common.log;/*
package com.circue.uaa.common.log;

import com.circue.uaa.constant.Oauth2Constants;
import com.circue.uaa.entity.UaaLog;
import com.circue.uaa.util.IpAddressUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

*/
/**
 * @description:
 * @author: zl
 * @date: 2023/12/25
 *//*

public class LogInterceptor implements HandlerInterceptor {


    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String clientIp = request.getParameter(Oauth2Constants.CLIENT_IP);
        if(clientIp==null){
            clientIp=IpAddressUtil.getClientIpAddress(request);
        }
        String requestURI = request.getRequestURI();
        UaaLog uaaLog=new UaaLog();
        uaaLog.setClientIp(clientIp);
        uaaLog.setPointUrl(requestURI);
        uaaLog.setExecuteTime(System.currentTimeMillis());
        LogContextUtil.setContext(uaaLog);
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        HandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        UaaLog uaaLog = LogContextUtil.getContext();
        Long startTime = uaaLog.getExecuteTime();
        uaaLog.setExecuteTime(System.currentTimeMillis()- startTime);
        LogContextUtil.resetContext();
    }
}
*/
